trait Logger{
    def log(message: String):Unit
}
class Calculator extends Logger{
  def  add(x: Int, y: Int): Int={
     val sum=x+y
     log(s" $x + $y. Result: $sum")
     sum
  }
  def  subtract(x: Int, y: Int): Int={
     val subtract=x-y
     log(s" $x - $y. Result: $subtract")
     subtract
  }
  override def log(message: String): Unit = {
    println(message)
  }
}
val calculator = new Calculator ()
calculator.add(10,5) //输出“Adding 10 and 5. Result: 15~
calculator.subtract(10,5) //输出“Subtracting 5 from 10. Result: 5"